package com.zygh.policeasset.controller;

import com.alibaba.fastjson.JSONObject;
import com.zygh.policeasset.component.CommonResult;
import com.zygh.policeasset.pojo.NoticeAffiche;
import com.zygh.policeasset.service.NoticeAfficheService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping({"/notice-affiche"})
@Api(tags = {"通知公告"})
@RestController
/* loaded from: police-asset-2.0-0.0.1-SNAPSHOT.jar:BOOT-INF/classes/com/zygh/policeasset/controller/NoticeAfficheController.class */
public class NoticeAfficheController {
    @Autowired
    NoticeAfficheService NoticeAfficheService;

    @RequestMapping(value = {"/findAll"}, method = {RequestMethod.GET})
    @ApiOperation("查询全部")
    public Object findAll(@RequestParam(defaultValue = "1", value = "pageNum") int pageNum, @RequestParam(defaultValue = "10", value = "pageSize") int pageSize, NoticeAffiche noticeAffiche) {
        return this.NoticeAfficheService.findAll(pageNum, pageSize, noticeAffiche);
    }

    @RequestMapping(value = {"/findAllByUserId"}, method = {RequestMethod.GET})
    @ApiOperation("APP根据用户id查询全部")
    public Object findAllByUserId(@RequestParam(defaultValue = "1", value = "pageNum") int pageNum, @RequestParam(defaultValue = "10", value = "pageSize") int pageSize, @RequestParam(value = "userId", required = false) Integer userId, @RequestParam(value = "type", required = false) Integer type, @RequestParam(value = "status", required = false) Integer status) {
        return this.NoticeAfficheService.findAllByUserId(pageNum, pageSize, userId, type, status);
    }

    @RequestMapping(value = {"/SelectById"}, method = {RequestMethod.GET})
    @ApiOperation("通过id查询")
    public Object SelectById(@RequestParam("id") Integer id) {
        return this.NoticeAfficheService.SelectById(id);
    }

    @ApiResponses({@ApiResponse(code = 200, message = "OK", response = CommonResult.class)})
    @RequestMapping(value = {"/add"}, method = {RequestMethod.POST})
    @ApiOperation("添加")
    public Object add(@RequestBody NoticeAffiche noticeAffiche) {
        return this.NoticeAfficheService.add(noticeAffiche);
    }

    @ApiResponses({@ApiResponse(code = 200, message = "OK", response = CommonResult.class)})
    @DeleteMapping({"/delete/{id}"})
    @ApiOperation("删除")
    public Object delete(@PathVariable Integer id) {
        return this.NoticeAfficheService.delete(id);
    }

    @ApiResponses({@ApiResponse(code = 200, message = "OK", response = CommonResult.class)})
    @PostMapping({"/update"})
    @ApiOperation("修改")
    public Object update(@RequestBody NoticeAffiche noticeAffiche) {
        return this.NoticeAfficheService.update(noticeAffiche);
    }

    @PostMapping({"/updateRead"})
    @ApiImplicitParam(name = "json", value = "noticeAfficheId是通知公告id,userId是用户id", required = true, paramType = "query")
    @ApiOperation("APP端标记为已读")
    public Object updateRead(@RequestBody JSONObject json) {
        return this.NoticeAfficheService.updateRead(json.getInteger("noticeAfficheId"), json.getInteger("userId"));
    }
}